﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Browser;

namespace FTG.Silverlight.Google.Analytics {
    /// <summary>
    /// Google analytics tracker.
    /// </summary>
    public class Tracker {

        /// <summary>
        /// Track page
        /// </summary>
        /// <param name="page">page name or url</param>
        public static void TrackPage(string page) {
            try {
                HtmlPage.Window.Eval(string.Format("_gaq.push(['_trackPageview', '{0}'])", page));
            }
            catch (Exception) { }
        }

        /// <summary>
        /// Tracks event
        /// </summary>
        /// <param name="category">event category</param>
        /// <param name="action">event action</param>
        public static void TrackEvent(string category, string action) {
            try{
            HtmlPage.Window.Eval(string.Format("_gaq.push(['_trackEvent', '{0}', '{1}'])", category, action));
            }
            catch (Exception) { }
        }

        /// <summary>
        /// Track event
        /// </summary>
        /// <param name="category">event category</param>
        /// <param name="action">event action</param>
        /// <param name="label">event label</param>
        public static void TrackEvent(string category, string action, string label) {
            try{
            HtmlPage.Window.Eval(string.Format("_gaq.push(['_trackEvent', '{0}', '{1}', '{2}'])", category, action, label));
            }
            catch (Exception) { }
        }
    }
}
